Assigning Colors to Shapes
Colors exist to affect the appearance of drawn shapes. QuickDraw GX shapes other than bitmaps and pictures get their color from the ink object that is part of the shape. One property of the ink object is color, agxColor
structure that describes the color of the associated shape.To assign or change a shape's color, therefore, you typically call the
GXSetInkColor
function for the ink associated with the shape whose color you are assigning. You can also callGXSetShapeColor
, which performs the same task but allows you the convenience of specifying the shape object involved, rather than the ink object that actually contains the color information. (Conversely, to inspect the color of a shape,
you callGXGetInkColor
orGXGetShapeColor
.) TheGXSetInkColor
,GXSetShapeColor
,GXGetInkColor
, andGXGetShapeColor
functions are described in the chapter "Ink Objects" in this book.Shapes that need more than one color are a special case. Bitmap shapes do not use the color information in their ink object. Instead, the color of each pixel in a bitmap shape
is specified as a pixel value in thegxBitmap
structure; depending on the storage size
of each pixel, that pixel value may be an actual color value or it may be an index
into a color set. To set the color of an individual pixel in a bitmap, you call theGXSetShapePixel
function, specifying which pixel to modify and what its new
color or new index value is. (Conversely, you can inspect the color of a pixel by
callingGXGetShapePixel
.)Modifying the color values in a color set, as described in the section "Manipulating the Colors in a Color Set Object" on page 4-47, is another way to change the color or colors of a shape. In a bitmap using indexed color space, any pixels whose indexes refer to color values you have modified will be changed in appearance, even though their pixel values remain unchanged. You can use this technique to perform simple manipulations of a shape's colors.
Bitmap shapes, the
gxBitmap
structure, and the functionsGXSetShapePixel
andGXGetShapePixel
are described in the bitmap shapes chapter of Inside Macintosh: QuickDraw GX Graphics.